home *** CD-ROM | disk | FTP | other *** search
/ Champak 40 / Vol 40.iso / games / bee_dodg.swf / scripts / frame_6 / DoAction.as
Encoding:
Text File  |  2007-05-10  |  5.7 KB  |  244 lines

  1. function createSmall()
  2. {
  3.    cursmall = attachMovie("small","enemy" + n,n);
  4.    n++;
  5.    n <= 50 ? null : (n = 0);
  6.    cursmall._x = 800;
  7.    cursmall._y = 25 + random(301);
  8.    cursmall.xspd = beeSpd + 8 + random(4);
  9.    cursmall.yspd = Math.random() * 6 - 3;
  10.    cursmall.grav = 0;
  11.    cursmall.onEnterFrame = beeMove;
  12. }
  13. function createMedium()
  14. {
  15.    curmedium = attachMovie("medium","enemy" + n,n);
  16.    n++;
  17.    n <= 50 ? null : (n = 0);
  18.    curmedium._x = 800;
  19.    curmedium._y = 25 + random(301);
  20.    curmedium.xspd = beeSpd + 6 + random(3);
  21.    curmedium.yspd = Math.random() * 4 - 2;
  22.    curmedium.grav = 0;
  23.    curmedium.onEnterFrame = beeMove;
  24. }
  25. function createBig()
  26. {
  27.    curbig = attachMovie("big","enemy" + n,n);
  28.    n++;
  29.    n <= 50 ? null : (n = 0);
  30.    curbig._x = 900;
  31.    curbig._y = random(301) + 25;
  32.    curbig.xspd = beeSpd + 4 + random(2);
  33.    curbig.yspd = Math.random() * 2 - 1;
  34.    curbig.grav = 0;
  35.    curbig.onEnterFrame = beeMove;
  36. }
  37. function createShooter()
  38. {
  39.    curshooter = attachMovie("shooter","enemy" + n,n);
  40.    n++;
  41.    n <= 50 ? null : (n = 0);
  42.    curshooter._x = 800;
  43.    curshooter._y = random(275) - 100;
  44.    curshooter.xspd = 10;
  45.    curshooter.yspd = Math.random() * -6 - 3;
  46.    curshooter.shooter = true;
  47.    curshooter.onEnterFrame = beeMove;
  48. }
  49. function createStinger(a, b)
  50. {
  51.    curStinger = attachMovie("stinger","stinger" + s,s);
  52.    s++;
  53.    s <= 600 ? null : (s = 500);
  54.    curStinger._x = a;
  55.    curStinger._y = b;
  56.    curStinger.xspd = 15;
  57.    curStinger.onEnterFrame = beeMove;
  58. }
  59. function createHealth()
  60. {
  61.    curHealth = attachMovie("health","health" + n,n);
  62.    n++;
  63.    n <= 50 ? null : (n = 0);
  64.    curHealth._x = 750;
  65.    curHealth._y = Math.random() * 350 + 25;
  66.    curHealth.xspd = Math.random() * 5 + 3;
  67.    curHealth.health = true;
  68.    curHealth.onEnterFrame = beeMove;
  69. }
  70. function createCoin()
  71. {
  72.    curCoin = attachMovie("coin","coin" + c,c);
  73.    c++;
  74.    c <= 200 ? null : (c = 100);
  75.    curCoin._x = 750;
  76.    curCoin._y = Math.random() * 350 + 25;
  77.    curCoin.coin = true;
  78.    curCoin.xspd = 7 + Math.random() * 6;
  79.    curCoin.onEnterFrame = beeMove;
  80. }
  81. function beeMove()
  82. {
  83.    if(_currentframe != 6)
  84.    {
  85.       this.removeMovieClip();
  86.    }
  87.    if(this._x < -300 || this._y > 600)
  88.    {
  89.       this.removeMovieClip();
  90.    }
  91.    this._x -= this.xspd;
  92.    this._y -= this.yspd;
  93.    this.yspd -= this.grav;
  94.    if(this.coin == true)
  95.    {
  96.       if(this.hitTest(_root.bee) && this._currentframe < 12)
  97.       {
  98.          this.gotoAndPlay(12);
  99.       }
  100.       if(this._currentframe == 21)
  101.       {
  102.          score += 200;
  103.          burst(this._x,this._y,3);
  104.          this.removeMovieClip();
  105.       }
  106.    }
  107.    if(this.shooter == true)
  108.    {
  109.       this.xspd = Math.ceil((this._x - 600) / 5);
  110.       this.yspd = - this.xspd;
  111.       if(this._currentframe == 91)
  112.       {
  113.          this.removeMovieClip();
  114.       }
  115.       if(this._x <= 550)
  116.       {
  117.          this.play();
  118.       }
  119.       if(this._currentframe == 13)
  120.       {
  121.          createStinger(this._x,this._y);
  122.       }
  123.    }
  124.    if(this.health == true)
  125.    {
  126.       if(this.hitTest(_root.bee) && this._currentframe == 1)
  127.       {
  128.          this.play();
  129.       }
  130.       if(this._currentframe == 17)
  131.       {
  132.          if(_root.bee.health < 11)
  133.          {
  134.             _root.bee.health = _root.bee.health + 1;
  135.          }
  136.          else
  137.          {
  138.             score += 200;
  139.          }
  140.          burst(this._x,this._y,4);
  141.          this.removeMovieClip();
  142.       }
  143.    }
  144. }
  145. function burst(a, d, c)
  146. {
  147.    i = 0;
  148.    while(i < 15)
  149.    {
  150.       curStar = attachMovie("bstar","star" + b,b);
  151.       b++;
  152.       b <= 400 ? null : (b = 300);
  153.       curStar.gotoAndStop(random(c) + 1);
  154.       c != 10 ? null : curStar.gotoAndStop(random(2) + 4);
  155.       curStar._xscale = 50 + random(101);
  156.       curStar._yscale = curStar._xscale;
  157.       curStar._x = a;
  158.       curStar._y = d;
  159.       curStar.xspd = Math.random() * 10 - 5;
  160.       curStar.yspd = Math.random() * 10 - 3;
  161.       curStar.grav = 0.5;
  162.       curStar.onEnterFrame = beeMove;
  163.       i++;
  164.    }
  165. }
  166. n = 0;
  167. b = 300;
  168. c = 100;
  169. s = 500;
  170. xspd = 0;
  171. yspd = 0;
  172. grav = 0;
  173. score = 0;
  174. realScore = 0;
  175. counter = 5;
  176. cCounter = 150;
  177. hCounter = 400;
  178. shCounter = 250;
  179. sCounter = 100;
  180. mCounter = 200;
  181. bCounter = 300;
  182. shooter = false;
  183. heatlh = false;
  184. beeSpd = 0;
  185. onEnterFrame = function()
  186. {
  187.    burstCounter--;
  188.    if(_currentframe == 6)
  189.    {
  190.       n <= 50 ? null : (n = 0);
  191.       if(realScore < score)
  192.       {
  193.          realScore += 1 + Math.floor((score - realScore) / 10);
  194.       }
  195.       if(counter <= 1 && _root.bee.health > 0)
  196.       {
  197.          score += 5;
  198.          counter = 5;
  199.       }
  200.       if(sCounter <= 0)
  201.       {
  202.          createSmall();
  203.          sCounter = Math.max(250 + random(40) - Math.abs(score / 30),20);
  204.       }
  205.       if(mCounter <= 0)
  206.       {
  207.          createMedium();
  208.          mCounter = Math.max(275 + random(55) - Math.abs(score / 35),25);
  209.       }
  210.       if(bCounter <= 0)
  211.       {
  212.          createBig();
  213.          bCounter = Math.max(300 + random(60) - Math.abs(score / 40),30);
  214.       }
  215.       if(shCounter <= 0)
  216.       {
  217.          createShooter();
  218.          shCounter = Math.max(285 + random(55) - Math.abs(score / 38),28);
  219.       }
  220.       if(hCounter <= 0)
  221.       {
  222.          createHealth();
  223.          hCounter = 350 + random(100);
  224.       }
  225.       if(cCounter <= 0)
  226.       {
  227.          createCoin();
  228.          cCounter = 125 + random(50);
  229.       }
  230.       if(beeSpd < 20)
  231.       {
  232.          beeSpd = Math.floor(realScore / 1150);
  233.       }
  234.       counter--;
  235.       cCounter--;
  236.       hCounter--;
  237.       shCounter--;
  238.       sCounter--;
  239.       mCounter--;
  240.       bCounter--;
  241.       _root.bg.gotoAndStop(Math.ceil(realScore / 10) - Math.floor(realScore / 5000) * 500);
  242.    }
  243. };
  244.